export function formatSize(bytesize: bigint): string {
  const size = bytesize
  const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
  let i = 0
  let nsize = Number(size)
  while (nsize > 1024) {
    nsize = nsize / 1024
    i++
  }
  return nsize.toFixed(2) + units[i]
}

export function formatTime(time: bigint): string {
  let totalSeconds = Number(time)
  const days = Math.floor(totalSeconds / 86400)
  totalSeconds %= 86400
  const hours = Math.floor(totalSeconds / 3600)
  totalSeconds %= 3600
  const minutes = Math.floor(totalSeconds / 60)
  const seconds = totalSeconds % 60

  return `${days}:${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
}
